#!/bin/sh
dir=$1
filename2=$(find $dir -name '*.txt')
dirname1=$(find $dir -name '*.txt'|xargs dirname)
dirname=$(date -d "1 day ago" +"%Y-%m-%d")
for i in $filename2
  do
    if [ -d $dirname ];then
      mv $i $dirname
    else
      mkdir $dirname
      mv $i $dirname
    fi
  done
